package com.effectiv.gooruda.rest.api.controller;

import java.util.List;

import javax.validation.Valid;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import lombok.extern.slf4j.Slf4j;
import com.effectiv.gooruda.rest.api.domain.Email;
import com.effectiv.gooruda.rest.api.operation.EmailOperations;


@Slf4j
@Controller
@RequestMapping("/email")
public class EmailController implements EmailOperations {
	
	@Autowired
	@Qualifier("emailServiceImpl")
	private EmailOperations operations;
	
	
	
	@RequestMapping(value="/send/{configName}", method=RequestMethod.POST)
	@Override
	public @ResponseBody void send(@PathVariable  String configName, @Valid @RequestPart Email email, @RequestPart(required=false) 
			List<MultipartFile>  attachments , @RequestPart(required=false) List<MultipartFile>  inlines ) {
		log.info("configName = {}", configName);
		log.info("email = {}", email);
		
		
		log.info("files = {}", attachments);
		log.info("files = {}", attachments.size());
		
		log.info("inlines = {}", inlines);
		log.info("inlines = {}", inlines.size());
		
		//operations.send(configName, email, file);
	}
	
	
	//TODO - Expose the API in doc and playground
	
	/*
	@Override
	
	public @ResponseBody Email[] receive(@PathVariable  String configName) {
		
		return operations.receive(configName);
	}
	*/
	

}
